package com.jiale.ojsystem.judge.codesandbox;

import com.jiale.ojsystem.judge.codesandbox.modle.ExecuteCodeRequest;
import com.jiale.ojsystem.judge.codesandbox.modle.ExecuteCodeResponse;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;

/**
 * 代码沙箱代理类
 */
@Slf4j
public class CodeSandBoxProxy implements CodeSandBox{

    @Resource
    private CodeSandBox codeSandBox;

    /**
     * 带参构造，方便接收代码沙箱工厂生产的不同种类代码沙箱
     * @param codeSandBox
     */
    public CodeSandBoxProxy(CodeSandBox codeSandBox){
        this.codeSandBox=codeSandBox;
    }

    @Override
    public ExecuteCodeResponse doExecute(ExecuteCodeRequest executeCodeRequest) {
        log.info("执行代码请求{}",executeCodeRequest);
        ExecuteCodeResponse executeCodeResponse = codeSandBox.doExecute(executeCodeRequest);
        return executeCodeResponse;
    }
}
